package com.itlong.cloud.equip.commons;

import com.itlong.cloud.POJO.DTO.property.CloudIntercomChangeLogGetDTO;
import com.itlong.cloud.POJO.VO.common.CloudEntranceVO;
import com.itlong.cloud.POJO.VO.property.*;
import com.itlong.cloud.utils.page.Page;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 *      云门禁业务处理暴露接口
 * </desc>
 *
 * @createDate 2019/02/22
 */
@FeignClient(name = "equip-service")
public interface ICloudEntranceServiceClient {

    /**
     * <desc>
     *      检测门禁是否存在
     * </desc>
     *
     * @param sn
     * @param deviceType 17代表云门禁 22代表云联动器
     * @return
     * @author Jiaqi.X
     * @createDate 2019/02/21
     */
    @RequestMapping(path = "/smartCommunity/interface/entrance/checkSnExists",method = RequestMethod.POST)
    String checkSnExists(@RequestParam("sn") String sn,@RequestParam("doorCount") Integer doorCount,@RequestParam("deviceType") String deviceType);

    /**
     * <desc>
     *      通过token获取用户信息
     * </desc>
     *
     * @param token
     * @return
     * @author Jiaqi.X
     * @createDate 2019/02/26
     */
    @RequestMapping(path = "/smartCommunity/interface/entrance/retrieve",method = RequestMethod.POST)
    CloudEntranceVO retrieve(@RequestParam("token")String token);

    /**
     * <desc>
     *      更新云门禁缓存iot信息
     * </desc>
     *
     * @param cloudEntranceVO
     * @return
     * @author Juguang.S
     * @createDate 2019/02/26
     */
    @RequestMapping(path = "/smartCommunity/interface/entrance/updateCloudEntranceIotCacheInfo",method = RequestMethod.POST)
    CloudEntranceVO updateCloudEntranceIotCacheInfo(@RequestBody CloudEntranceVO cloudEntranceVO);

    /**
     * <desc>
     *      根据sn查询该设备信息
     * </desc>
     *
     * @param sn
     * @return
     * @author Juguang.S
     * @createDate 2019/02/26
     */
    @RequestMapping(path = "/smartCommunity/interface/entrance/getDeviceInfoBySn",method = RequestMethod.POST)
    Map<String,Object> getDeviceInfoBySn(@RequestParam("sn")String sn,@RequestParam(value = "doorCount",required = false) Integer doorCount);

    /**
     * <desc>
     *      云门禁登录
     * </desc>
     *
     * @param sn
     * @param doorCount 控制器控制门数
     * @param encryptionAbility 加密传输方法 0不加密传输 1自有加密方案 2https安全传输
     * @return
     * @author Jiaqi.X
     * @createDate 2019/02/21
     */
    @RequestMapping(path = "/smartCommunity/interface/entrance/login",method = RequestMethod.POST)
    CloudEntranceVO login(@RequestParam("sn") String sn,@RequestParam("doorCount") Integer doorCount,
                          @RequestParam("encryptionAbility") Integer encryptionAbility,
                          @RequestParam(value = "deviceType", required = false) String deviceType) throws Exception;

    /**
     * <desc>
     *      添加云门禁用户身份证通行记录
     * </desc>
     *
     * @param userInfo 用户信息
     * @author wangzhi
     * @createDate 2019/02/28
     */
    @PostMapping(path = "/smartCommunity/interface/entrance/saveIdCardPassRecord")
    Integer saveIdCardPassRecord(@RequestBody Map<String, Object> userInfo) throws Exception;

    /**
     * <desc>
     *      获取云门禁轮询命令
     * <desc/>
     *
     * @param getDTO 轮询命令分页
     * @return
     * @author Qiang.S
     * @createDate 2019-03-04
     */
    @RequestMapping(path = "/smartCommunity/interface/entrance/getDeviceChangeLogOrders",method = {RequestMethod.POST})
    Page<CloudEntranceChangeLogPageVO> getDeviceChangeLogOrders(@RequestBody CloudIntercomChangeLogGetDTO getDTO) throws Exception;

    /**
     * <desc>
     *     云门禁设备批量完成轮询命名
     * </desc>
     *
     * @param sn
     * @param ids 轮询命令，多个以英文逗号拼接
     * @return 受影响的行数
     * @throws Exception
     * @author Qiang.S
     * @createDate 2019-03-04
     */
    @PostMapping(path = "smartCommunity/interface/entrance/batchFinishChangeLogOrders")
    Integer batchFinishChangeLogOrders(@RequestParam("sn") String sn,
                                       @RequestParam("ids") String ids) throws Exception;

    /**
     * <desc>
     *     通知云端升级失败原因
     * </desc>
     *
     * @param sn
     * @param id 轮询命令
     * @param msg 失败原因
     * @return 受影响的行数
     * @throws Exception
     * @author Qiang.S
     * @createDate 2019-06-25
     */
    @PostMapping(path = "smartCommunity/interface/entrance/reportUpdateResult")
    Integer reportUpdateResult(@RequestParam("sn") String sn,
                               @RequestParam("id") String id,
                               @RequestParam("msg") String msg) throws Exception;

    /**
     *      门禁开放控制指令
     * </desc>
     *
     * @param sourceForm 来源 默认itlong
     * @param mainDeviceUnique 控制器门禁设备序列号
     * @param doorNum   子门禁设备机号，多个，号分隔
     * @param openCtrl  开门控制类型：0关门 1开门
     * @param timeout 开门时长：范围 0-300，0保持常开，1-300开门时长，单位s
     * @param productKey iot产品key
     * @param userId 开门用户id
     * @param correlationId 开门事件唯一id
     * @param robotFlag 机器人标识,1为机器人开门
     *
     * @author Jiaqi.X
     * @createDate 2019/02/27
     */
    @PostMapping(path = "/smartCommunity/interface/entrance/entranceOpenOrCloseCtrl")
    void entranceOpenOrCloseCtrl(@RequestParam(value = "sourceForm",required = false) String sourceForm,
                                        @RequestParam(value = "mainDeviceUnique",required = false) String mainDeviceUnique,
                                        @RequestParam(value = "doorNum",required = false) String doorNum,
                                        @RequestParam(value = "openCtrl",required = false) String openCtrl,
                                        @RequestParam(value = "timeout",required = false) String timeout,
                                        @RequestParam(value = "productKey",required = false) String productKey,
                                        @RequestParam(value = "userId",required = false) String userId,
                                        @RequestParam(value = "correlationId",required = false) String correlationId,
                                        @RequestParam(value = "robotFlag",required = false) String robotFlag) throws Exception;

    /**
     * <desc>
     *      联动器开放控制指令
     * </desc>
     *
     * @param sourceForm 来源 默认itlong
     * @param mainDeviceUnique 控制器门禁设备序列号
     * @param doorNum   子门禁设备机号，多个，号分隔
     * @param openCtrl  开门控制类型：0关门 1开门
     * @param timeout 开门时长：范围 0-300，0保持常开，1-300开门时长，单位s
     * @param productKey iot产品key
     * @param userId 开门用户id
     * @param type 开门类型
     * @param doorDirection 门方向:0背门,1正门
     * @param floor 真实楼层例:1,2,3,4
     * @param correlationId 开门事件唯一id
     * @param robotFlag 机器人标识,1为机器人开门
     *
     * @author Qiang.S
     * @createDate 2019/05/27
     */
    @PostMapping(path = "/smartCommunity/interface/entrance/wippenOpenOrCloseCtrl")
    void wippenOpenOrCloseCtrl(@RequestParam(value = "sourceForm",required = false) String sourceForm,
                                 @RequestParam(value = "mainDeviceUnique",required = false) String mainDeviceUnique,
                                 @RequestParam(value = "doorNum",required = false) String doorNum,
                                 @RequestParam(value = "openCtrl",required = false) String openCtrl,
                                 @RequestParam(value = "timeout",required = false) String timeout,
                                 @RequestParam(value = "productKey",required = false) String productKey,
                                 @RequestParam(value = "userId",required = false) String userId,
                                 @RequestParam(value = "type",required = false) String type,
                                 @RequestParam(value = "doorDirection",required = false) String doorDirection,
                                 @RequestParam(value = "floor",required = false) String floor,
                                 @RequestParam(value = "correlationId",required = false) String correlationId,
                                 @RequestParam(value = "robotFlag",required = false) String robotFlag,
                               @RequestParam(value = "modeFloor",required = false) String modeFloor
    ) throws Exception;

    /**
     * <desc>
     *      获取iot门禁账号及关联的产品id
     * </desc>
     *
     * @param deviceUnique
     * @return
     * @author Jiaqi.X
     * @createDate 2019/03/04
     */
    @PostMapping(path = "/smartCommunity/interface/entrance/getMainDeviceUniqueAndProductKey")
    Map<String, Object> getMainDeviceUniqueAndProductKey(@RequestParam("deviceUnique") String deviceUnique);

    /**
     *      获取iot门禁账号及关联的产品id
     * </desc>
     *
     * @param projectId
     * @return
     * @author Jiaqi.X
     * @createDate 2019/03/04
     */
    @PostMapping(path = "/smartCommunity/interface/entrance/getMainDeviceUniqueAndProductKeyByProjectId")
    List<Map<String, Object>> getMainDeviceUniqueAndProductKeyByProjectId(@RequestParam("projectId") String projectId);

    /**
     * <desc>
     *      获取云门禁或联动器设备更新信息
     * </desc>
     *
     * @param sn
     * @param productType 2云门禁,4联动器
     * @return
     * @author Qiang.S
     * @createDate 2018/08/30
     */
    @RequestMapping(path = "smartCommunity/interface/entrance/deviceEntranceUpdate")
    CloudDeviceUpdateInfoVO deviceEntranceUpdate(@RequestParam("sn") String sn, @RequestParam("productType") String productType)  throws Exception;

    /**
     * <desc>
     *      获取一体式人脸识别门禁更新信息
     * </desc>
     *
     * @param sn
     * @param deviceType 软件类型 4 维护程序，5 业务程序，6 桌面程序，7 通信程序
     * @return
     * @author Qiang.S
     * @createDate 2020/05/25
     */
    @RequestMapping(path = "smartCommunity/interface/entrance/deviceUnibodyFaceUpdate")
    CloudDeviceUpdateInfoVO deviceUnibodyFaceUpdate(@RequestParam("sn") String sn, @RequestParam("deviceType") String deviceType) throws Exception;

    /**
     * <desc>
     *      判断sn存在性
     * <desc/>
     *
     * @param sn
     * @return
     * @author Juguang.S
     * @createDate 2019-03-07
     */
    @RequestMapping(path = "smartCommunity/interface/entrance/checkSnExist",method = {RequestMethod.POST})
    Integer checkSnExist(@RequestParam("sn") String sn) throws Exception;

    /**
     * <desc>
     *      根据sn查询同为一个控制器的设备唯一码
     * <desc/>
     *
     * @param sn
     * @return
     * @author Qiang.S
     * @createDate 2019-03-14
     */
    @RequestMapping(path = "smartCommunity/interface/entrance/getSameControllerDevice",method = {RequestMethod.POST})
    List<String> getSameControllerDevice(@RequestParam("sn") String sn) throws Exception;

    /** <desc>
     *      门禁状态上报控制
     * </desc>
     *
     * @param sourceForm 来源 默认itlong
     * @param mainDeviceUnique 控制器门禁设备序列号
     * @param doorNum   需要控制的门禁设备序列号，多个,号分隔
     * @param timeout 超时时长 范围0-300，0表示设备立刻停止上报
     * @param productKey iot产品key
     *
     * @author Jiaqi.X
     * @createDate 2019/02/27
     */
    @RequestMapping(path = "smartCommunity/interface/entrance/entranceStatusCtrl",method = {RequestMethod.POST})
    void entranceStatusCtrl(@RequestParam("sourceForm")String sourceForm,@RequestParam("mainDeviceUnique")String mainDeviceUnique,
                                    @RequestParam("doorNum")String doorNum,@RequestParam("timeout")String timeout,@RequestParam("productKey")String productKey) throws Exception;

    /**
     * <desc>
     *      获取门禁设备iot信息
     * <desc/>
     *
     * @param deviceUnique 设备编号
     * @return
     * @author Qiang.S
     * @createDate 2019-03-15
     */
    @RequestMapping(path = "smartCommunity/interface/entrance/getDoorIotInfo",method = {RequestMethod.POST})
    CloudEntranceVO getDoorIotInfo(@RequestParam("deviceUnique") String deviceUnique) throws Exception;

    /**
     * <desc>
     *      获取门禁黑名单分页列表
     * </desc>
     *
     * @param cloudEntranceVO
     * @return
     * @author Jiaqi.X
     * @createDate 2019/10/14
     */
    @RequestMapping(path = "smartCommunity/interface/entrance/pullBlackList",method = {RequestMethod.POST})
    DeviceBlackListPageVO<EntranceBlackListVO> pullBlackList(@RequestBody CloudEntranceVO cloudEntranceVO);

     /**
     * <desc>
     *      获取门禁、联动器临时权限
     * </desc>
     *
     * @param vo
     * @return
     * @author Jiaqi.X
     * @createDate 2019/09/11
     */
    @RequestMapping(path = "smartCommunity/interface/entrance/getTempAuths",method = {RequestMethod.POST})
    DeviceAuthTempPageVO<EntranceTempAuthPageVO> getTempAuths(@RequestBody CloudEntranceVO vo) throws Exception;

    /**
     * <desc>
     *      生成人脸指令
     * </desc>
     *
     * @param deviceUnique  人脸识别仪编号
     * @param userId   用户编号
     * @return
     * @author Qiang.S
     * @createDate 2020/06/03
     */
    @RequestMapping(path = "smartCommunity/interface/entrance/createUserInstruct",method = {RequestMethod.POST})
    void createUserInstruct(@RequestParam("deviceUnique") String deviceUnique,@RequestParam("userId") String userId) throws Exception;

    /**
     * <desc>
     *      获取门禁人脸识别配置信息
     * </desc>
     *
     * @param sn
     * @return
     * @author Jiaqi.X
     * @createDate 2018/05/21
     */
    @RequestMapping(path = "smartCommunity/interface/entrance/getDoorFaceInfo")
    CloudTalkFaceApplyInfoVO getDoorFaceInfo(@RequestParam("sn") String sn) throws Exception;

    /**
     * <desc>
     *      根据sn 获取状态
     * </desc>
     *
     * @param
     * @return
     * @author caoshuai
     * @createDate 2020/12/27 11:44
     */
    @RequestMapping(path = "smartCommunity/interface/entrance/getStatusBySn")
    String getStatusBySn(@RequestParam("sn") String sn);
}
